import Vue from 'vue';
import main from './main.vue';
const MessageBoxConstructor = Vue.extend(main);
let instance;
const MessageBox = function(data) {
  return new Promise((resolve, reject) => {
    instance = new MessageBoxConstructor({ data: data });
    instance.callback = (action) => {
      if (action) {
        resolve(action);
      } else {
        reject(action);
      }
      instance.$el.parentNode.removeChild(instance.$el);
    };
    instance.$mount();
    document.body.appendChild(instance.$el);
  });
};

export default MessageBox;
